SELECT TOP (5)
ProductID,
EndDate,
DATEPART(YEAR, EndDate) AS [Year],
DATEPART(MONTH, EndDate) AS [Month],
DATEPART(DAY, EndDate) AS [Day]
FROM Production.ProductCostHistory
WHERE EndDate IS NOT NULL;

SELECT MyData ,
ISDATE(MyData) AS IsADate
FROM (VALUES('IsThisADate'),
('2012-02-14'),
('2012-01-01T00:00:00'),
('2012-12-31T23:59:59.9999999')) dt(MyData);

go



SELECT MyData,
EOMONTH(MyData) AS LastDayOfThisMonth,
EOMONTH(MyData, 1) AS LastDayOfNextMonth
FROM (VALUES ('2012-02-14T00:00:00' ),
('2012-01-01T00:00:00'),
('2012-12-31T23:59:59.9999999')) dt(MyData);
SELECT MyData from (Values('YONG')) dt(MyData)

SELECT MyData FROM (values ('2012-12-31T23:59:59.9999999')) dt(MyData);

SELECT 'DateFromParts' AS ConversionType,
DATEFROMPARTS(2012, 8, 15) AS [Value];
SELECT 'TimeFromParts' AS ConversionType,
TIMEFROMPARTS(18, 25, 32, 5, 1) AS [Value];
SELECT 'SmallDateTimeFromParts' AS ConversionType,
SMALLDATETIMEFROMPARTS(2012, 8, 15, 18, 25) AS [Value];
SELECT 'DateTimeFromParts' AS ConversionType,
DATETIMEFROMPARTS(2012, 8, 15, 18, 25, 32, 450) AS [Value];
SELECT 'DateTime2FromParts' AS ConversionType,
DATETIME2FROMPARTS(2012, 8, 15, 18, 25, 32, 5, 7) AS [Value];
SELECT 'DateTimeOffsetFromParts' AS ConversionType,
DATETIMEOFFSETFROMPARTS(2012, 8, 15, 18, 25, 32, 5, 4, 0, 7) AS [Value];